<template>
  <div>
    <template>
      <div>
        <el-table :data="buildingNumberList" border stripe height="860" :summary-method="getSummaries" show-summary
        :header-cell-style="{'text-align':'center'}" :cell-style="{'text-align':'center'}">
          <el-table-column prop="" label="单体成本分摊明细表（二）">
            <template slot-scope="scope">
              <el-table :data="scope.row.list" :show-header="scope.$index === 0" :header-cell-style="{'text-align':'center'}" :cell-style="{'text-align':'center'}">
                <el-table-column prop="type_title" label="业态">
                </el-table-column>
                <el-table-column prop="area" label="建筑面积" :formatter="stateFormat">
                </el-table-column>
                <el-table-column prop="sold_ratio" label="已售比例" :formatter="soldPerCent">
                </el-table-column>
                <el-table-column prop="land_ratio" label="土地分摊比例">
                </el-table-column>
                <el-table-column prop="area_ratio" label="其他分摊比例">
                </el-table-column>
                <el-table-column prop="land_area" label="分摊的土地面积" :formatter="stateFormat">
                </el-table-column>
                <el-table-column prop="land_syq" label="分摊土地使用权支付金额" :formatter="stateFormat">
                </el-table-column>
                <el-table-column prop="land_cq" label="分摊土地征用及拆迁补偿费" :formatter="stateFormat">
                </el-table-column>
                <el-table-column prop="sum_qtcb" label="分摊的其他成本" :formatter="stateFormat">
                </el-table-column>
                <el-table-column prop="sum_exclusive" label="专属成本" :formatter="stateFormat">
                </el-table-column>
                <el-table-column prop="a_sum_exclusive" label="分摊成本合计" :formatter="stateFormat">
                </el-table-column>


              </el-table>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </template>
  </div>
</template>

<script>
import calculateApi from '@/api/calculate'

export default {
  data() {
    return {
      calculate_id: '',
      buildingNumberList: []
    }

  },
  methods: {
    getCalculateBuildingNumberList() {
      calculateApi.getCalculateBuildingNumberList(this.calculate_id).then(response => {
        this.buildingNumberList = response.data.list;
      })
    },
    rowClassName({ row, rowIndex }) {
      if (row.type === 6 || row.type === 10) {
        return 'warning-row';
      }
      if (row.c_sum_exclusive == 0) {
        return 'warning-row';
      }
      return '';
    },
    soldPerCent(row) {
      if (row.type_title == '合计') {
        return '';
      }
      return row.sold_ratio + "%";
    },
  },
  created() {
    var query = this.$route.query;
    if (query.id) {
      this.calculate_id = query.id;
    }

    this.getCalculateBuildingNumberList();
  },
}
</script>

<style>
.el-table .warning-row {
  display: none;
}
</style>